from estados.Estados import New
from random import randint

class PCB():
    #INICIALIZACION
    
    ###constructor
    def __init__(self, aProgram, pid): 
        self.program = aProgram
        self.id = pid
        self.currentInstruction = 0
        self.state= New()
        self.priority = randint(1, 10)
        self.pcbQuantum = 0

###############################################################################################################

    #METODOS   
    def isFinish(self):
        return self.lenInstructions() == self.getCurrentInstruction()
    def incrementarPriority(self):
        self.priority += 1
    def lenInstructions(self):
        return self.program.lenCodigo()
    def aumentarInstruction(self):
        self.currentInstruction = self.currentInstruction + 1
###############################################################################################################

    #GET&SET                  
    def getProgram(self):
        return self.program
    def getId(self):
        return self.id
    def getCurrentInstruction(self):
        return self.currentInstruction
    def getInstruction(self):
        return self.program.getCodigo()[self.currentInstruction]
    def getState(self):
        return self.state.getName()
    def getPriority (self):
        return self.priority
    def setState(self, state):
        self.state = state
    def setPriority (self, newPriority):
        self.priority = newPriority